﻿using UnityEngine;
using System.Collections;

public class Item : MonoBehaviour {

    public float xOffset = -2.0f;
    public float yOffset = -4.0f;
    public int columnIndex;
    public int rowIndex;
    public GameController game;
    public bool movable = true;
    public void UpdatePosition()
    {
        this.transform.position = new Vector3(columnIndex * 0.5f + xOffset +((rowIndex % 2 == 0) ? 0.5f : 0), rowIndex * 0.5f + yOffset, 0);
    }

    public void MoveItem(int columnIndex, int rowIndex)
    {
        this.columnIndex = columnIndex;
        this.rowIndex = rowIndex;
        UpdatePosition();
    }

    void OnMouseDown()
    {
        if (movable)
        {
            if (game.started)
            {
                game.CreatePot(game.pot2, columnIndex, rowIndex);
                Debug.Log("你点击了" + columnIndex + "列" + rowIndex + "行");
                movable = false;
                ArrayList steps = game.GetCatSteps();
                foreach (Vector2 vector in steps)
                {
                    Debug.Log("最终的steps");
                    Debug.Log(vector.x + "&&" + vector.y);
                }
                Cat cat = game.cat.GetComponent<Cat>();
                cat.RandomStep(steps);
            }
        }
    }
}
